// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
  return cloud.callFunction({
    name: "model_student",
    data: {
      op: "select",
      key: "_id",
      value: event.student_id
    }
  }).then(res => {
    // console.log(res.result.data);
    if (res.result.data[0].default == 1) {
      return -1;
    }

    return cloud.callFunction({
      name: "model_student",
      data: {
        op: "delete",
        id: event.student_id
      }
    }).then(res => { return res.result; })
  })

}